home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************
- * *
- * (C) Copyright 2002 - 2004, Human Concepts (tm) *
- * *
- ***********************************************************
- * File name: indexPage.js *
- * Author: Andrey Ponomarev *
- **********************************************************/
-
- window.onload = doInit
- window.onresize = onResize
-
-
- var bCapture = false
-
- function onResize()
- {
- var nWidth = document.body.clientWidth
-
- if( typeof(PersonList) == "object" )
- PersonList.style.width = nWidth + 3
- }
-
- function doInit()
- {
- CreateControls()
- var obj = parent.hcMain
- if ( typeof (obj) == "object" && typeof (obj.onNavigatePageInit) != "undefined" )
- obj.onNavigatePageInit()
- }
-
- var idxArray = null;
- var idxCount = 0;
-
- function fillIndexArray(person)
- {
- AddToArray( person );
- var spanObjs = person.children.tags("span");
-
- for(var j = 0; j < spanObjs.length; ++j)
- fillIndexArray(spanObjs[j]);
- }
-
- function AddToArray( p_oPerson )
- {
- var paramObjs = p_oPerson.getElementsByTagName("param");
- var obj = null;
- for (i = 0; i < paramObjs.length; ++i)
- {
- var o = paramObjs[i];
- if (o.id == GetPrimaryFld())
- {
- obj = o;
- break;
- }
- }
-
- if( obj != null )
- {
- idxArray[idxCount] = new Object();
- idxArray[idxCount].Text = obj.name;
- idxArray[idxCount].url = p_oPerson.src;
- idxCount++;
- }
- }
-
- function sortFunct( a, b )
- {
- return IsAsc() ? a.Text < b.Text : b.Text < a.Text;
- }
-
- var bFilled = 0;
-
- function fillPage(group)
- {
- if( typeof( parent.hcPersons ) != "object" )
- {
- parent.hcMain.focus();
- return;
- }
-
- if( bFilled ) return;
-
- var fieldsObj = parent.hcMain.getFieldsObj()
- if(fieldsObj == null) return
-
- if( ProcessHeaders(fieldsObj) == -1 )
- return; //Error!
-
- // var id = group.id
- // var objPerson = parent.hcMain.findPersonNode(id,null)
- // if(objPerson == null) return
- var objPerson = parent.hcMain.getPersonsObj().children[0];
- idxArray = new Array()
- idxCount = 0
-
- fillIndexArray(objPerson);
- var r = idxArray.sort( sortFunct );
-
- for (j = 0; j < idxArray.length; j++)
- AddListItem( idxArray[j].Text, idxArray[j].url );
-
- parent.hcMain.focus();
- bFilled = 1;
- }
-
- function ProcessHeaders(objHeaders)
- {
- if( typeof(objHeaders) != "object" )
- return -1;
-
- var strTitle = "";
- var paramObjs = objHeaders.getElementsByTagName("param");
-
- for (var j = 0; j < paramObjs.length; j++)
- {
- var obj = paramObjs[j];
-
- if( obj.name != null && obj.id == GetPrimaryFld() )
- {
- strTitle = obj.name;
- if( typeof( TitleText ) == "undefined" || TitleText == null )
- continue;
- TitleText.innerText = "Persons (" + strTitle + "):"; //Loc
-
- return obj.id;
- }
- }
-
- return -1;
- }
-
- function CreateControls()
- {
- if ( typeof(TitleText) == 'undefined' )
- {
- var elem = document.createElement("span");
- elem.id = "TitleText";
- document.body.appendChild(elem);
- }
-
- if( typeof( PersonList ) == 'undefined' )
- {
- var elem = document.createElement("<table>");
- elem.id = 'PersonList';
- var oRow = elem.insertRow( 0 );
- oRow.insertCell(0);
-
- document.body.appendChild( elem );
- }
- onResize()
- }
-
- function AddListItem( str, url )
- {
- if (typeof(str) != "undefined" && str != "")
- {
- var u = document.createElement( '<ul></ul>' );
- var elem = document.createElement( '<li></li>' );
- elem.innerHTML = '<span class="indexItem" _url="' + url + '" onclick="OnPersonDblClicked();">' + str + '</a>';
-
- PersonList.rows[0].cells[0].appendChild(u);
- PersonList.rows[0].cells[0].childNodes[0].appendChild(elem);
- }
- }
-
- function OnPersonDblClicked()
- {
- var obj = event.srcElement;
- ShowBox( obj._url );
- }
-
- function ShowBox(strSrc)
- {
- var hcMain = parent.hcMain
- var s = strSrc.split("#")
- if(s.length!=2) return;
-
- if(s[0].length!=0)
- {
- if( hcMain.location.pathname.indexOf(s[0]) != -1 )
- hcMain.navigateBox(s[1]);
- else
- hcMain.location.replace(strSrc)
- }
- else
- {
- hcMain.navigateBox(s[1]);
- }
- }
-